import {
  getEntireDepartments,
  getEntireMenus,
  getEntireRoles
} from '@/service/main/main'
import type { IMainState } from '@/types/main'
import { defineStore } from 'pinia'

export const useMainStore = defineStore('main_store', {
  state: (): IMainState => ({
    entireRoles: [],
    entireDepartments: [],
    menus: []
  }),
  actions: {
    async fetchEntireDataAction() {
      const rolesResult = await getEntireRoles()
      const deparmentsResult = await getEntireDepartments()
      const menuResult = await getEntireMenus()
      this.entireRoles = rolesResult.data.list
      this.entireDepartments = deparmentsResult.data.list
      this.menus = menuResult.data.list
    }
  }
})
